home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
xgakit.exe
/
XGAKIT.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-05-06
|
34KB
|
1,191 lines
;
; XGA Adapter Programmer's Toolkit, version 1.1
; by Bert Tyler of Tyler Software
; CIS ID: 73477,433
; (From Internet/BITNET: 73477.433@compuserve.com)
; Copyright 1990, 1991 Tyler Software
; (except, of course, for those parts copied right out of IBM's
; "Preliminary XGA Video Subsystem Hardware Users Guide")
; ((which is most of the code, really...))
;
; Free for use in commercial, shareware or freeware applications
;
; Routines in this module:
;
; int xga_detect()
; returns 0 if no XGA adapter found
; non-zero if XGA adapter found
; bits: 0 - XGA adapter found
; 1 - XGA monitor is color, not mono
; 2 - XGA monitor is high-rez - capable of 1024x768
; 3 - XGA adapter has 1MB of RAM
; 4 - XGA adapter is in a dual-monitor setup
; (IE, return code of 7 means XGA adapter with 512K of RAM
; connected to a high-rez color monitor in a single-
; monitor setup)
;
; int xga_mode(int mode)
; mode = 0 to enter normal VGA text mode (BIOS mode 3)
; 1 to enter 132-col VGA text mode
; 2 to enter 1024x768x256 graphics mode
; 3 to enter 1024x768x16 graphics mode
; 4 to enter 640x480x256 graphics mode
; 5 to enter 640x480x65536 graphics mode
; 6 to enter 800x600x16 graphics mode
; 7 to enter 800x600x256 graphics mode
; 8 to enter 800x600x65536 graphics mode
; returns 0 on failure
; 1 on success
; (NOTE! You *must* use 'xga_mode(0)' to exit any of the
; other modes and get back to standard VGA operation, even
; on a dual-monitor (XGA & VGA) setup! On a dual-monitor
; setup, 'xga_mode(0)' leaves the XGA image intact, but
; disables the XGA adapter's 64K aperture at A000:0000)
;
; void xga_putpixel(int row, int col, int color)
; writes pixel (row, col) using color
; (all pixel counts start at 0, and [0][0] is in the UL corner)
;
; int xga_getpixel(int row, int col)
; returns color of pixel at (row, col)
; (all pixel counts start at 0, and [0][0] is in the UL corner)
;
; void xga_putline(int row, int firstcol, int lastcol, char *pixels)
; sends the line segment directly to the video
; (all pixel counts start at 0, and [0][0] is in the UL corner)
; (IE, xga_putline(3,7,12,*pixels) sends pixel[0] thru pixel[5]
; to the 8th thru 13th pixel in the fourth row)
;
; void xga_getline(int row, int firstcol, int lastcol, char *pixels)
; reads the line segment directly from the video
; (all pixel counts start at 0, and [0][0] is in the UL corner)
; (IE, xga_putline(3,7,12,*pixels) fills pixel[0] thru pixel[5]
; from the 8th thru 13th pixel in the fourth row)
;
; void xga_setpalette(char *palette)
; where 'palette' points to a 768-byte array of RGB values
; (values from 0-255, not the VGA's internal 0-63!)
;
.MODEL medium,c
.DATA
public xga_isinmode ; (only public for Fractint purposes)
public xga_clearvideo ; (only public for Fractint purposes)
xga_pos_base dw 0 ; MCA Pos Base value
xga_cardid dw 0 ; MCA Card ID value
xga_reg_base dw -1 ; XGA IO Reg Base (-1 means dunno yet)
xga_1mb dd 0 ; XGA 1MB aperture address
xga_4mb dd 0 ; XGA 4MB aperture address
xga_result dw 0 ; XGA_detect result code
xga_isinmode dw 0 ; XGA is in this mode right now
xga_iscolors dw 0 ; XGA using this many colors (0=64K)
xga_clearvideo db 0 ; set to 80h to prevent video-clearing
xga_dotwrite dw 0 ; write-a-dot routine: mode-specific
xga_dotread dw 0 ; read-a-dot routine: mode-specific
xga_linewrite dw 0 ; write-a-line routine: mode-specific
xga_lineread dw 0 ; read-a-line routine: mode-specific
xga_curbk dw 0 ; bank number
xga_xdots dw 0 ; bytes per scan line
xga_linelen dw 0 ; line segment length
xga_offset dw 0 ; line segment offset
.CODE
; Graphics mode setup values
; (the first two entries in each line
; indicate where the table values are to be stored)
;
; 1024x768x256 vvv
; 1024x768x16 -----vvvv
; 640x480x256 -----------vvvv
; 640x480x65536 ----------------vvvv
; 800x600x16 -----------------------vvvv
; 800x600x256 -----------------------------vvvv
; 800x600x65536 ----------------------------------vvvv
xga_twidth dw 9 ; width of these tables
xga_requir dw 0, 0, 0dh, 05h, 01h, 09h, 01h, 01h, 09h ; adapter requirements
xga_colors dw 0, 0, 256, 16, 256, 0, 16, 256, 0 ; 0 means 64K colors
xga_swidth dw 0, 0, 1024, 512, 640, 1280, 400, 800, 1600 ; bytes / scan line
xga_val db 004h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; interrupt enable
db 005h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ; interrupt status
db 000h, 000h, 004h, 004h, 004h, 004h, 004h, 004h, 004h ; operating mode
db 00ah, 064h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; palette mask
db 001h, 000h, 001h, 001h, 001h, 001h, 001h, 001h, 001h ; vid mem aper cntl
db 008h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; vid mem aper indx
db 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; virt mem ctl
db 009h, 000h, 003h, 002h, 003h, 004h, 002h, 003h, 004h ; mem access mode
db 00ah, 050h, 001h, 001h, 001h, 001h, 001h, 001h, 001h ; disp mode 1
db 00ah, 050h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; disp mode 1
db 00ah, 010h, 09dh, 09dh, 063h, 063h, 088h, 088h, 088h ; horiz tot lo.
db 00ah, 011h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; horiz tot hi.
db 00ah, 012h, 07fh, 07fh, 04fh, 04fh, 063h, 063h, 063h ; hor disp end lo
db 00ah, 013h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; hor disp end hi
db 00ah, 014h, 07fh, 07fh, 04fh, 04fh, 063h, 063h, 063h ; hor blank start lo
db 00ah, 015h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; hor blank start hi
db 00ah, 016h, 09dh, 09dh, 063h, 063h, 088h, 088h, 088h ; hor blank end lo
db 00ah, 017h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; hor blank end hi
db 00ah, 018h, 087h, 087h, 055h, 055h, 06ah, 06ah, 06ah ; hor sync start lo
db 00ah, 019h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; hor sync start hi
db 00ah, 01ah, 09ch, 09ch, 061h, 061h, 084h, 084h, 084h ; hor sync end lo
db 00ah, 01bh, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; hor sync end hi
db 00ah, 01ch, 040h, 040h, 000h, 000h, 000h, 000h, 000h ; hor sync pos
db 00ah, 01eh, 004h, 004h, 000h, 000h, 000h, 000h, 000h ; hor sync pos
db 00ah, 020h, 030h, 030h, 00ch, 00ch, 086h, 086h, 086h ; vert tot lo
db 00ah, 021h, 003h, 003h, 002h, 002h, 002h, 002h, 002h ; vert tot hi
db 00ah, 022h, 0ffh, 0ffh, 0dfh, 0dfh, 057h, 057h, 057h ; vert disp end lo
db 00ah, 023h, 002h, 002h, 001h, 001h, 002h, 002h, 002h ; vert disp end hi
db 00ah, 024h, 0ffh, 0ffh, 0dfh, 0dfh, 057h, 057h, 057h ; vert blank start lo
db 00ah, 025h, 002h, 002h, 001h, 001h, 002h, 002h, 002h ; vert blank start hi
db 00ah, 026h, 030h, 030h, 00ch, 00ch, 086h, 086h, 086h ; vert blank end lo
db 00ah, 027h, 003h, 003h, 002h, 002h, 002h, 002h, 002h ; vert blank end hi
db 00ah, 028h, 000h, 000h, 0eah, 0eah, 058h, 058h, 058h ; vert sync start lo
db 00ah, 029h, 003h, 003h, 001h, 001h, 002h, 002h, 002h ; vert sync start hi
db 00ah, 02ah, 008h, 008h, 0ech, 0ech, 06eh, 06eh, 06eh ; vert sync end
db 00ah, 02ch, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ; vert line comp lo
db 00ah, 02dh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ; vert line comp hi
db 00ah, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; sprite cntl
db 00ah, 040h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; start addr lo
db 00ah, 041h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; start addr me
db 00ah, 042h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; start addr hi
db 00ah, 043h, 080h, 040h, 050h, 0a0h, 032h, 064h, 0c8h ; pixel map width lo
db 00ah, 044h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; pixel map width hi
db 00ah, 054h, 00dh, 00dh, 000h, 000h, 001h, 001h, 001h ; clock sel
db 00ah, 051h, 003h, 002h, 003h, 004h, 002h, 003h, 004h ; display mode 2
db 00ah, 070h, 000h, 000h, 000h, 000h, 080h, 080h, 080h ; ext clock sel
db 00ah, 050h, 00fh, 00fh, 0c7h, 0c7h, 007h, 007h, 007h ; display mode 1
db 00ah, 055h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; Border Color
db 00ah, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h ; Sprite Pal Lo
db